package geyue.wechat.robot;

import com.blade.kit.StringKit;
import com.blade.kit.http.HttpRequest;

import geyue.wechat.Constant;

public class MoLiRobot implements Robot {

	private String apiUrl;

	public MoLiRobot() {
		
		
		//String api_key = Constant.config.get("itpk.api_key");
		//String api_secret = Constant.config.get("itpk.api_secret");
		
		String api_key ="f0dfde2ce1aca59ddc5750fe6c868e7f";
		String api_secret = "wtd8p06so8fq";
				
		if(StringKit.isNotBlank(api_key) && StringKit.isNotBlank(api_secret)){
			this.apiUrl = Constant.ITPK_API + "?api_key=" + api_key + "&api_secret=" + api_secret;
		}
	}

	@Override
	public String talk(String msg) {
		System.out.println("----------------------------------------msg:"+msg+"\n");
		if(null == this.apiUrl){
			return "机器人未配置";
		}
//		apiUrl = "http://res.cuiyongzhi.com/2016/03/201603086749_6850.png";
		
		
		String url = apiUrl + "&question=" + msg;
		String result = HttpRequest.get(url).connectTimeout(3000).body();
		return result;
	}

}
